package com.cnwidsom.filter;

import com.cnwidsom.monitor.MonitorItem;

public abstract class LogDataFilter implements Filter {

	public abstract boolean filter(MonitorItem mi);

	public abstract String getFilterName();

	public int compareTo(Filter o) {
		return this.getFilterName().compareTo(o.getFilterName());
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof LogDataFilter) {
			return ((LogDataFilter) obj).getFilterName().equals(this.getFilterName());
		}
		return false;
	}

	@Override
	public int hashCode() {
		return 0;
	}

	public void filter(FilterChain chain, Object obj) throws BreakException {
		if (filter((MonitorItem) obj)) {
			chain.doChain(obj);
		} else {
			throw new BreakException();
		}
	}
}
